package jp.sourceforge.talisman.csvio.builder;

/*
 * $Id: CsvLineBuilderFactory.java,v 1.1 2009/09/12 05:06:11 weiwei Exp $
 */

import jp.sourceforge.talisman.csvio.CsvIOSetting;
import jp.sourceforge.talisman.csvio.CsvLineBuilder;

/**
 * 
 * @author Haruaki Tamada
 * @version $Revision: 1.1 $ $Date: 2009/09/12 05:06:11 $
 */
public class CsvLineBuilderFactory{
    private static final CsvLineBuilderFactory factory = new CsvLineBuilderFactory();

    private CsvLineBuilderFactory(){
        // singleton pattern
    }

    public static CsvLineBuilderFactory getInstance(){
        return factory;
    }

    public CsvLineBuilder createBuilder(){
        return createBuilder(new CsvIOSetting());
    }

    public CsvLineBuilder createBuilder(CsvIOSetting setting){
        CsvLineBuilder builder = null;

        switch(setting.getQuotationMode()){
        case ALWAYS:
        case AS_NEEDED:
            builder = new QuoteAsNeededCsvLineBuilder(setting);
            break;
        case NEVER:
            builder = new NoQuoteCsvLineBuilder(setting);
            break;
        }
        return builder;
    }
}
